import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import "./index.scss";
import { RouterProvider, createHashRouter } from "react-router-dom";
import Home from "./pages/home/index.jsx";
import Cart from "./pages/cart/index.jsx";
import User from "./pages/user/index.jsx";
import Login from "./pages/login.jsx";
import Reg from "./pages/reg.jsx";
import ProtectedRouter from "./components/protectedRouter.jsx";
import Lists from "./pages/List/index.jsx";
import Detail from "./pages/List/detail.jsx";
import Dialog from "./pages/List/dialog.jsx";

import GoodsDetail from "./pages/home/detail.jsx";
import UserInfo from "./pages/user/userinfo.jsx";
import SearchDetail from "./pages/home/searchDetail.jsx";
const router = createHashRouter([
  {
    path: "login",
    element: <Login />,
  },
  {
    path: "reg",
    element: <Reg />,
  },
  {
    path: "dialog/:id",
    element: <Dialog />,
  },
  {
    path: "goods/:id",
    element: <GoodsDetail />,
  },
  {
    path: "/",
    element: <App />,
    children: [
      {
        path: "searchDetail",
        element: <SearchDetail />,
      },
      {
        index: true,
        element: <Home />,
      },

      {
        path: "lists",
        element: <Lists />,
      },
      {
        path: "lists/:id",
        element: <Detail />,
      },
      {
        path: "cart",
        element: (
          <ProtectedRouter>
            <Cart />
          </ProtectedRouter>
        ),
      },
      {
        path: "user",
        element: (
          <ProtectedRouter>
            <User />
          </ProtectedRouter>
        ),
      },
      {
        path: "userinfo",
        element: (
          <ProtectedRouter>
            <UserInfo></UserInfo>
          </ProtectedRouter>
        ),
      },
    ],
  },
]);
ReactDOM.createRoot(document.getElementById("root")).render(
  <RouterProvider router={router} />
);
